import { createRouter, createWebHistory } from 'vue-router'
import Layout from '../layout/Layout.vue'
import Login from "@/views/Login";
import Register from "@/views/Register";
import Person from "@/views/Person";
import User from "@/views/User";
import Book from "@/views/Book";
import News from "@/views/News";
import Category from "@/views/Category";
import Home from "@/views/Home";

const routes = [
  {
    path: '',
    name: 'Layout',
    component: Layout,
    redirect: "/user",
    //嵌套路由
    children:[
      {
        path: 'user',
        name: 'User',
        component: User
      },
      {
        path: "/person",
        name: "Person",
        component: Person
      },
      {
        path: "/book",
        name: "Book",
        component: Book
      },
      {
        path: "/news",
        name: "News",
        component: News
      },
      {
        path: "/category",
        name: "Category",
        component: Category
      },
      {
        path: "/home",
        name: "Home",
        component: Home
      }
    ]
  },
  {
    path: '/login',
    name: "Login",
    component: Login
  },
  {
    path: '/register',
    name: "Register",
    component: Register
  },

]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
